# -*- coding: utf-8 -*-

import threading

import config
 
'''多线程获取Figure的json数据'''
class FigureThread(threading.Thread):
    def __init__(self, fetchDirector, queue):
        threading.Thread.__init__(self)
        self.fetchDirector = fetchDirector
        self.queue = queue

    def run(self):
        while True:
            skip = self.queue.get()
            print "开始获取Figure数据 +++ 页码： %s" % (skip)
            data = self.fetchDirector.getHomeDataBySkip(skip * config.FIGURE1_PAGESIZE)
            print "完成获取Figure数据 --- 页码： %s" % (skip)
            self.fetchDirector.saveHomeDataToFile(data, skip)
            print "本地写入Figure数据 --- 页码： %s" % (skip)
            self.queue.task_done()
